﻿#include "pch.h"
#include "Texture.h"

#include "function/RenderSystem/AbstractRenderer.h"
#include "function/RenderSystem/OpenGL/OpenGLTexture2D.h"

namespace Engine
{
	Ref<Texture2D> Texture2D::Create(const std::string& path)
	{
		switch (AbstractRenderer::GetAPI())
		{
		case RendererAPI::API::None:
			ENGINE_ASSERT(false, "无 Renderer API！")
				return nullptr;
#if PLATFORM_WINDOWS
		case RendererAPI::API::OpenGL:
			return std::make_shared<OpenGLTexture2D>(path);
		case RendererAPI::API::Direct3D:
			return nullptr;
		case RendererAPI::API::Vulcan:
			return nullptr;
#elif PLATFORM_MAC
		case RendererAPI::Metal:
			return nullptr;
#endif
		default:
			ENGINE_ASSERT(false, "未知的 Renderer API！")
				return nullptr;
		}
	}
	Ref<Texture2D> Texture2D::Create(int width, int height)
	{
		switch (AbstractRenderer::GetAPI())
		{
		case RendererAPI::API::None:
			ENGINE_ASSERT(false, "无 Renderer API！")
				return nullptr;
#if PLATFORM_WINDOWS
		case RendererAPI::API::OpenGL:
			return std::make_shared<OpenGLTexture2D>(width, height, nullptr); // nullptr 代表没有纹理数据
		case RendererAPI::API::Direct3D:
			return nullptr;
		case RendererAPI::API::Vulcan:
			return nullptr;
#elif PLATFORM_MAC
		case RendererAPI::Metal:
			return nullptr;
#endif
		default:
			ENGINE_ASSERT(false, "未知的 Renderer API！")
				return nullptr;
		}
	}
}
